#pragma once
#include <stdio.h>
#include <iostream>
#include <map>
#include <string>
#include "tinyxml.h"
class TiXmlHelper
{
public:
	TiXmlHelper();
	~TiXmlHelper();
	bool Load(const char* szFilePath);
	void Save();
	bool CreateDoc();
	void Save(const char* szFilePath);
	bool SetChildValue(std::string child, std::string value, std::string parent, int nSameNameSeq = 1);
	bool SetChildProperty(std::string child, std::string propertyName, std::string propertyValue, std::string parent, int nSameNameSeq = 1);
	std::string GetChildValue(const std::string child, const std::string parent, int nSameNameSeq = 1);
	std::string GetChildProperty(const  std::string child, const  std::string propertyName, const  std::string parent, int nSameNameSeq = 1);
	std::string  DocDump();
private:		
	TiXmlElement * FindNode(TiXmlElement* parent, const char* szNodeName, int nSameNameSeq = 1) const;
	TiXmlElement * FindNodeV2(TiXmlElement* parent, const char* szNodeName, int nSameNameSeq=1);
	TiXmlElement * VisitChildElt(TiXmlElement* elt, const char* szNodeName, int nSameNameSeq = 1);
	TiXmlElement * VisitChildSiblingElt(TiXmlElement* elt, const char* szNodeName,int nSameNameSeq = 1);
	void FreeDoc();
private:
	TiXmlDocument *m_pDoc = nullptr;
	TiXmlElement *m_pRoot = nullptr;	
	std::string m_filePath;
};

